Developer --> Technical Publications

     


Handling Events

To respond to events generated by the user and Navigation Services, you can create an event-handling function, described in this document as . You register your event-handling function by passing a Universal Procedure Pointer (UPP) in the eventProc parameter of a Navigation Services function such as . You obtain this UPP by calling the macro NewNavEventProc and passing a pointer to your event-handling function. If an event occurs while the Open dialog box is displayed, for example, the function will call your event-handling function. In the callBackParms parameter of your event-handling function, supplies a structure of type . This structure contains the information your application needs to respond to the event. For instance, your application can obtain the event record describing the event to be handled from the pointer in the event field of the structure.

When calling your event-handling function, Navigation Services passes only the update events that apply to your windows and only the mouse-down events that occur in the preview or customization areas.

You are strongly encouraged to provide at least a simple function to handle update events. If you do this, Navigation Services dialog boxes automatically become movable and resizable. Listing 2-6 shows an example of such a function.

Listing 2-6 A sample event-handling function
pascal void myEventProc(NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, NavCallBackUserData callBackUD) { WindowPtr window = (WindowPtr)callBackParms->eventData.event->message; switch (callBackSelector) { case kNavCBEvent: switch (((callBackParms->eventData) .eventDataParms).event->what) { case updateEvt: MyHandleUpdateEvent(window, (EventRecord*)callBackParms->eventData.event); break; } break; } }

In your event-handling function, you can also call the function to control various aspects of dialog boxes. For example, the following line shows how you can determine whether the preview area is currently showing:

NavCustomControl(context, kNavCtlIsPreviewShowing, &isShowing);

If you extend the type pop-up menus with custom menu items, Navigation Services expects your event-handling function to respond to these items. For more information, see Customizing Type Pop-up Menus.


© 2000 Apple Computer, Inc. (Last Updated 18 April 00)